package day8;

import banking.domain.OverdraftException;
import banking.reports.CustomerReport;

public class TestBanking {
    public static void main(String[] args) {
        // 创建银行实例并添加客户
        Bank bank = Bank.getBanking();

        // 添加客户和账户（示例）

        Customer customer1 = new Customer("Jane", "Simms");
        SavingAccount savingAccount = new SavingAccount(500.00, 0.03);
        customer1.addAccount(savingAccount);
        CheckingAccount checkingAccount = new CheckingAccount(200.00, 500.00); // 设置透支保护额度
        customer1.addAccount(checkingAccount);
        bank.addCustomer(customer1);

        Customer customer2 = new Customer("Owen", "Bryant");
        CheckingAccount checkingAccount2 = new CheckingAccount(200.00);
        customer2.addAccount(checkingAccount2);
        bank.addCustomer(customer2);

        // 添加 Customer:Soley,Tim U7 及其账户
        Customer customer3 = new Customer("Tim U7", "Soley");
        SavingAccount savingAccount3 = new SavingAccount(1500.00, 0.03);
        customer3.addAccount(savingAccount3);
        CheckingAccount checkingAccount3 = new CheckingAccount(200.00, 500.00);
        customer3.addAccount(checkingAccount3);
        bank.addCustomer(customer3);

        // 添加 Customer:Soley,Tim 及其账户
        Customer customer4 = new Customer("Tim", "Soley");
        CheckingAccount checkingAccount4 = new CheckingAccount(200.00, 500.00);
        customer4.addAccount(checkingAccount4);
        SavingAccount savingAccount4 = new SavingAccount(150.00, 0.03);
        customer4.addAccount(savingAccount4);
        bank.addCustomer(customer4);

        // 测试 Jane Simms 的账户操作
        try {
            checkingAccount.withdraw(150.00);
            checkingAccount.deposit(22.50);
            checkingAccount.withdraw(147.62);
            checkingAccount.withdraw(470.00);
        } catch (OverdraftException e) {
        }

        // 测试 Owen Bryant 的账户操作
        try {
            checkingAccount2.withdraw(100.00);
            checkingAccount2.deposit(25.00);
            checkingAccount2.withdraw(175.00);
        } catch (OverdraftException e) {
        }

        // 调用 CustomerReport 的 generateReport 方法
        CustomerReport report = new CustomerReport();
        report.generateReport();
    }
}